package com.china08.yxyapi.api.manage.edu.platform.statistics.resource;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.yxyresource.statistics.StatisticsWeiKeService;

import io.swagger.annotations.ApiOperation;

/**
 * 教育局平台办公 数据统计 数据总览 微课数据总览
 * 
 */
@CrossOrigin
@RestController
public class StatisticsSrhWeiKeController extends YxyApiBaseController{
	@Autowired
    private StatisticsWeiKeService statisticsWeiKeService;
	
	@ApiOperation(value = "资源数据总览     微课数据总览")
	@ResponseBody
	@RequestMapping(value = "/api_yw/manage/edu/platform/statistics/weike/srh", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public RespModel precess(HttpServletRequest request, HttpServletResponse response) {
        RespModel model = new RespModel();
        StatisticsResourceModel2 statisticsResourceModel=new StatisticsResourceModel2();
        
        Integer schoolBureauLevel =getProfile(request, response).getSchoolBureauLevel();
        String districtCode=null;
        if (schoolBureauLevel==0) {
        	districtCode=getProfile(request, response).getSchoolAreaIdDistrict();
		}else if(schoolBureauLevel==1){
			districtCode=getProfile(request, response).getSchoolAreaIdCity();
		}else if(schoolBureauLevel==2){
			districtCode=getProfile(request, response).getSchoolAreaIdProvince();
		}
        //调用此方法查询资源数据总览数据
        List<Long> countLst= statisticsWeiKeService.statisticsResourceCount(districtCode,schoolBureauLevel);
        statisticsResourceModel.resourceCount = countLst.get(0);
        statisticsResourceModel.areaResourceCount = countLst.get(1);
        statisticsResourceModel.nearResourceCount = countLst.get(2);
        model.statisticsResourceModel=statisticsResourceModel;
        return model;
    }
    protected static class RespModel extends YxyApiRespModel {
    	
    	//统计资源数据总览模型
        public StatisticsResourceModel2 statisticsResourceModel;
    }
}
/**
 * 统计资源数据总览模型
 */
class StatisticsResourceModel2{
	//资源总数量
	public Long resourceCount;
	//区域资源数量
	public Long areaResourceCount;
	//最近新增资源
	public Long nearResourceCount;
}